﻿using System;
using System.ComponentModel.DataAnnotations;
using CRM.Models.Email;

namespace CRM.ViewModels.Email
{
    public class EmailTemplateCreateVM
    {
        public int Id { get; set; }
        public int OemId { get; set; }
        public int CompanyId { get; set; }
        public int GroupId { get; set; }
        public int UserId { get; set; }
        [MinLength(1)]
        public string Title { get; set; }
        public int Type { get; set; }
        public int Attribute { get; set; }
        [MinLength(1)]
        public string TemplateContent { get; set; }
        //public List<string> Images
        //{
        //    get => ImagesStr.Split(',').ToList();
        //    set => ImagesStr = string.Join(',', value);
        //}

        public EmailTemplate NewModel(Models.User user)
        {
            return new() {
                OemId = user.OemId, 
                CompanyId = user.CompanyId,
                GroupId = user.GroupId,
                UserId = user.Id,
                Title = Title,
                Type = Type,
                Attribute = Attribute,
                TemplateContent = TemplateContent,
                CreatedAt = DateTime.Now
            };
        }
        public EmailTemplate EditModel(EmailTemplate model)
        {
            model.Title = Title;
            model.TemplateContent = TemplateContent;
            model.Type = Type;
            model.Attribute = Attribute;
            return model;
        }
        
    }
    public class EmailTemplateListQuery
    {
        public DateTime[] CreatedAt { get; set; }
        public string Title { get; set; }
        public int? Type { get; set; }
        public int? Attribute { get; set; }
        public int Limit { get; set; }
        public int Page { get; set; }
    }
}